package com.nbsaas.boot.product.rest.convert;

import com.nbsaas.boot.product.data.entity.Product;
import com.nbsaas.boot.product.api.domain.simple.ProductSimple;

import com.nbsaas.boot.rest.api.Converter;

/**
* 产品-列表对象转换器
*/

public class ProductSimpleConvert implements Converter<ProductSimple, Product> {




@Override
public ProductSimple convert(Product source) {
    ProductSimple result = new ProductSimple();

                result.setNote(source.getNote());

               try {
                   if(source.getCreator()!=null){
                       result.setCreator(source.getCreator().getId());
                   }
                } catch (Exception ignored) { }

                result.setIntroduce(source.getIntroduce());

                try {
                    if(source.getProductCatalog()!=null){
                        result.setProductCatalogName(source.getProductCatalog().getName());
                    }
                } catch (Exception ignored) { }


                try {
                    if(source.getCreator()!=null){
                        result.setCreatorName(source.getCreator().getName());
                    }
                } catch (Exception ignored) { }

                result.setAddDate(source.getAddDate());
                result.setUrl(source.getUrl());

               try {
                   if(source.getProductCatalog()!=null){
                       result.setProductCatalog(source.getProductCatalog().getId());
                   }
                } catch (Exception ignored) { }

                result.setName(source.getName());
                result.setLogo(source.getLogo());
                result.setSortNum(source.getSortNum());
                if(source.getStoreState()!=null){
                    result.setStoreStateName(String.valueOf(source.getStoreState()));
                }
                result.setStoreState(source.getStoreState());
                result.setId(source.getId());
                result.setLastDate(source.getLastDate());


    return result;
}

}